package com.kitten.dataAlign.job;

import com.kitten.dataAlign.constants.RedisKeyConstants;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @author kitten
 */
@Slf4j
@Component
public class TestJob {

    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @XxlJob(value = "TestJobHandler")
    public void execute() throws Exception {
        XxlJobHelper.log("XXL-JOB, test job execute success.");
        log.info("XXL-JOB, test job execute success.");

        String key = RedisKeyConstants.buildCountNoteKey(1234567890L);
        redisTemplate.opsForHash().put(key, RedisKeyConstants.FIELD_NOTE_LIKE_TOTAL, 100);
        redisTemplate.opsForValue().set(key, RedisKeyConstants.FIELD_NOTE_LIKE_TOTAL, 86400);    // 设置过期时间为一天
        log.info(" Redis Hash Execute Success.");

    }

}
